Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for missing lconv support in android #328

Merged
merged 1 commit into from
May 19, 2016

Conversation

dpantele
Copy link

Fixing #327

Better to check if this API really works on Android.
Also please check if that is an OK use for the StringRef.

@dpantele
Copy link
Author

@vitaut , do you have any idea why mingw fails and VS is fine? I don't have mingw environment at the moment

@dpantele
Copy link
Author

What I could do blindly is to catch std::runtime_error and use std::locale("") in that case.

@vitaut
Copy link
Contributor

vitaut commented May 18, 2016

Thanks for the PR. According to this thread:

The GCC's libstdc++ does not support locales other than the C locale on MinGW. Somebody has to implement it first.

So I changed it back to C locale but added a detection for empty lconv in 3cefa72. It would be even better to detect lconv::thousands_sep is there with SFINAE, but this simple solution should do for now. Does it work for you?

@Gachapen
Copy link
Contributor

Hi, I have the same issue, but your fix (3cefa72) does not work. It's choosing the default thousands_sep:

In file included from fmt/posix.h:48:0,
                 from fmt/posix.cc:33:
fmt/format.h: In function 'fmt::StringRef fmt::internal::thousands_sep()':
fmt/format.h:915:60: error: 'struct lconv' has no member named 'thousands_sep'
 fmt::StringRef thousands_sep() { return std::localeconv()->thousands_sep; }

Anything I can do to help?

@vitaut
Copy link
Contributor

vitaut commented May 18, 2016

@Gachapen Thanks for testing it. Could you check what is sizeof(lconv) on Android? I guess the size check is not very reliable, maybe I should use a proper SFINAE detection for thousands_sep.

@Gachapen
Copy link
Contributor

@vitaut Just checked, it is 1.

@vitaut
Copy link
Contributor

vitaut commented May 18, 2016

@Gachapen Thanks. Just realized that my "fix" is rubbish because the thousands_sep template is compiled anyway.

@Gachapen
Copy link
Contributor

@vitaut Hehe, yes I see that now too :)

This is a bit too complex for me (I'd just #ifdef it). I'll happily test any fix you can come up with.

@dpantele
Copy link
Author

I will do the proper SFINAE version right now.

@dpantele
Copy link
Author

SFINAE with c++98 looks really messy... What do you think about this approach? dpantele@998bd2c

@vitaut
Copy link
Contributor

vitaut commented May 19, 2016

@dpantele Definitely looks better but I wonder why the tests are failing on mingw.

@dpantele
Copy link
Author

@vitaut I haven't pushed changes to the pull request branch, now all builds pass.

@Gachapen
Copy link
Contributor

I can confirm that this now builds. Though is it safe to assume that the size should be less or equal to 1 when it has no members?

@vitaut
Copy link
Contributor

vitaut commented May 19, 2016

@dpantele Got it. Could you squash the commits and rebase to current master?

@Gachapen You are right, the size check is not very robust. A better option is to detect lconv::thousands_sep specifically using something like http://stackoverflow.com/a/1007175/471164, but it will require more work.

@dpantele
Copy link
Author

dpantele commented May 19, 2016

Ok, rebased and cleaned-up in 45a1509

@vitaut vitaut merged commit 559739e into fmtlib:master May 19, 2016
@vitaut
Copy link
Contributor

vitaut commented May 19, 2016

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants